Call setlocale (LC_ALL, ""). (#60606)
authorOwen Taylor <otaylor@redhat.com>
Wed, 10 Oct 2001 21:54:25 +0000 (21:54 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 10 Oct 2001 21:54:25 +0000 (21:54 +0000)
Wed Oct 10 12:48:38 2001  Owen Taylor  <otaylor@redhat.com>

* gtk/gtkmain.c (gtk_init_check): Call setlocale (LC_ALL, "").
(#60606)

* gtk/gtkmain.c (gtk_disable_setlocale): Add function
to disable calling setlocale (LC_ALL, "").

* gtk/gtkmain.c (gtk_set_locale): Indicate in the
docs that this function is not typically useful.

* gdk/x11/{gdkim-x11.c,gdkmain-x11.c,gdkprivate-x11.h}:
Automatically initialize GDK for the current locale
on gdk_init(). Don't reset locale to C when
XSupportsLocale() fails.

* gdk/linux-fb/gdkim-fb.c (gdk_set_locale): Remove
useless checks for UTF-8 locale breakage that mattered
only for X.

* examples/calendar/calendar.c
tests/{testgtk.c,testtext.c,testcalendar.c}: Remove calls to
gtk_set_locale().

* gtk/gtkiconfactory.c gtk/gtkitemfactory.c:
gdk_pixbuf_new_from_stream => gdk_pixbuf_new_from_inline.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/linux-fb/gdkim-fb.c
gdk/x11/gdkim-x11.c
gdk/x11/gdkmain-x11.c
gdk/x11/gdkprivate-x11.h

index 7a865042867d5078bc02ef5999bea47ffc190374..ac9a9e96d691bc92c74dd71b5d01ef948ba6fc44 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+Wed Oct 10 12:48:38 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check): Call setlocale (LC_ALL, "").
+       (#60606)
+
+       * gtk/gtkmain.c (gtk_disable_setlocale): Add function
+       to disable calling setlocale (LC_ALL, "").
+
+       * gtk/gtkmain.c (gtk_set_locale): Indicate in the 
+       docs that this function is not typically useful.
+
+       * gdk/x11/{gdkim-x11.c,gdkmain-x11.c,gdkprivate-x11.h}: 
+       Automatically initialize GDK for the current locale
+       on gdk_init(). Don't reset locale to C when
+       XSupportsLocale() fails.
+
+       * gdk/linux-fb/gdkim-fb.c (gdk_set_locale): Remove
+       useless checks for UTF-8 locale breakage that mattered
+       only for X.
+
+       * examples/calendar/calendar.c
+       tests/{testgtk.c,testtext.c,testcalendar.c}: Remove calls to 
+       gtk_set_locale().
+
+       * gtk/gtkiconfactory.c gtk/gtkitemfactory.c:
+       gdk_pixbuf_new_from_stream => gdk_pixbuf_new_from_inline.
+
 Wed Oct 10 21:13:46 2001  Kristian Rietveld  <kristian@planet.nl>
 
        * gtk/gtktreemodel.[ch]: added gtk_tree_model_get_iter_from_string().
index 7a865042867d5078bc02ef5999bea47ffc190374..ac9a9e96d691bc92c74dd71b5d01ef948ba6fc44 100644 (file)
@@ -1,3 +1,30 @@
+Wed Oct 10 12:48:38 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check): Call setlocale (LC_ALL, "").
+       (#60606)
+
+       * gtk/gtkmain.c (gtk_disable_setlocale): Add function
+       to disable calling setlocale (LC_ALL, "").
+
+       * gtk/gtkmain.c (gtk_set_locale): Indicate in the 
+       docs that this function is not typically useful.
+
+       * gdk/x11/{gdkim-x11.c,gdkmain-x11.c,gdkprivate-x11.h}: 
+       Automatically initialize GDK for the current locale
+       on gdk_init(). Don't reset locale to C when
+       XSupportsLocale() fails.
+
+       * gdk/linux-fb/gdkim-fb.c (gdk_set_locale): Remove
+       useless checks for UTF-8 locale breakage that mattered
+       only for X.
+
+       * examples/calendar/calendar.c
+       tests/{testgtk.c,testtext.c,testcalendar.c}: Remove calls to 
+       gtk_set_locale().
+
+       * gtk/gtkiconfactory.c gtk/gtkitemfactory.c:
+       gdk_pixbuf_new_from_stream => gdk_pixbuf_new_from_inline.
+
 Wed Oct 10 21:13:46 2001  Kristian Rietveld  <kristian@planet.nl>
 
        * gtk/gtktreemodel.[ch]: added gtk_tree_model_get_iter_from_string().
index 7a865042867d5078bc02ef5999bea47ffc190374..ac9a9e96d691bc92c74dd71b5d01ef948ba6fc44 100644 (file)
@@ -1,3 +1,30 @@
+Wed Oct 10 12:48:38 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check): Call setlocale (LC_ALL, "").
+       (#60606)
+
+       * gtk/gtkmain.c (gtk_disable_setlocale): Add function
+       to disable calling setlocale (LC_ALL, "").
+
+       * gtk/gtkmain.c (gtk_set_locale): Indicate in the 
+       docs that this function is not typically useful.
+
+       * gdk/x11/{gdkim-x11.c,gdkmain-x11.c,gdkprivate-x11.h}: 
+       Automatically initialize GDK for the current locale
+       on gdk_init(). Don't reset locale to C when
+       XSupportsLocale() fails.
+
+       * gdk/linux-fb/gdkim-fb.c (gdk_set_locale): Remove
+       useless checks for UTF-8 locale breakage that mattered
+       only for X.
+
+       * examples/calendar/calendar.c
+       tests/{testgtk.c,testtext.c,testcalendar.c}: Remove calls to 
+       gtk_set_locale().
+
+       * gtk/gtkiconfactory.c gtk/gtkitemfactory.c:
+       gdk_pixbuf_new_from_stream => gdk_pixbuf_new_from_inline.
+
 Wed Oct 10 21:13:46 2001  Kristian Rietveld  <kristian@planet.nl>
 
        * gtk/gtktreemodel.[ch]: added gtk_tree_model_get_iter_from_string().
index 7a865042867d5078bc02ef5999bea47ffc190374..ac9a9e96d691bc92c74dd71b5d01ef948ba6fc44 100644 (file)
@@ -1,3 +1,30 @@
+Wed Oct 10 12:48:38 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check): Call setlocale (LC_ALL, "").
+       (#60606)
+
+       * gtk/gtkmain.c (gtk_disable_setlocale): Add function
+       to disable calling setlocale (LC_ALL, "").
+
+       * gtk/gtkmain.c (gtk_set_locale): Indicate in the 
+       docs that this function is not typically useful.
+
+       * gdk/x11/{gdkim-x11.c,gdkmain-x11.c,gdkprivate-x11.h}: 
+       Automatically initialize GDK for the current locale
+       on gdk_init(). Don't reset locale to C when
+       XSupportsLocale() fails.
+
+       * gdk/linux-fb/gdkim-fb.c (gdk_set_locale): Remove
+       useless checks for UTF-8 locale breakage that mattered
+       only for X.
+
+       * examples/calendar/calendar.c
+       tests/{testgtk.c,testtext.c,testcalendar.c}: Remove calls to 
+       gtk_set_locale().
+
+       * gtk/gtkiconfactory.c gtk/gtkitemfactory.c:
+       gdk_pixbuf_new_from_stream => gdk_pixbuf_new_from_inline.
+
 Wed Oct 10 21:13:46 2001  Kristian Rietveld  <kristian@planet.nl>
 
        * gtk/gtktreemodel.[ch]: added gtk_tree_model_get_iter_from_string().
index 7a865042867d5078bc02ef5999bea47ffc190374..ac9a9e96d691bc92c74dd71b5d01ef948ba6fc44 100644 (file)
@@ -1,3 +1,30 @@
+Wed Oct 10 12:48:38 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check): Call setlocale (LC_ALL, "").
+       (#60606)
+
+       * gtk/gtkmain.c (gtk_disable_setlocale): Add function
+       to disable calling setlocale (LC_ALL, "").
+
+       * gtk/gtkmain.c (gtk_set_locale): Indicate in the 
+       docs that this function is not typically useful.
+
+       * gdk/x11/{gdkim-x11.c,gdkmain-x11.c,gdkprivate-x11.h}: 
+       Automatically initialize GDK for the current locale
+       on gdk_init(). Don't reset locale to C when
+       XSupportsLocale() fails.
+
+       * gdk/linux-fb/gdkim-fb.c (gdk_set_locale): Remove
+       useless checks for UTF-8 locale breakage that mattered
+       only for X.
+
+       * examples/calendar/calendar.c
+       tests/{testgtk.c,testtext.c,testcalendar.c}: Remove calls to 
+       gtk_set_locale().
+
+       * gtk/gtkiconfactory.c gtk/gtkitemfactory.c:
+       gdk_pixbuf_new_from_stream => gdk_pixbuf_new_from_inline.
+
 Wed Oct 10 21:13:46 2001  Kristian Rietveld  <kristian@planet.nl>
 
        * gtk/gtktreemodel.[ch]: added gtk_tree_model_get_iter_from_string().
index 7a865042867d5078bc02ef5999bea47ffc190374..ac9a9e96d691bc92c74dd71b5d01ef948ba6fc44 100644 (file)
@@ -1,3 +1,30 @@
+Wed Oct 10 12:48:38 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check): Call setlocale (LC_ALL, "").
+       (#60606)
+
+       * gtk/gtkmain.c (gtk_disable_setlocale): Add function
+       to disable calling setlocale (LC_ALL, "").
+
+       * gtk/gtkmain.c (gtk_set_locale): Indicate in the 
+       docs that this function is not typically useful.
+
+       * gdk/x11/{gdkim-x11.c,gdkmain-x11.c,gdkprivate-x11.h}: 
+       Automatically initialize GDK for the current locale
+       on gdk_init(). Don't reset locale to C when
+       XSupportsLocale() fails.
+
+       * gdk/linux-fb/gdkim-fb.c (gdk_set_locale): Remove
+       useless checks for UTF-8 locale breakage that mattered
+       only for X.
+
+       * examples/calendar/calendar.c
+       tests/{testgtk.c,testtext.c,testcalendar.c}: Remove calls to 
+       gtk_set_locale().
+
+       * gtk/gtkiconfactory.c gtk/gtkitemfactory.c:
+       gdk_pixbuf_new_from_stream => gdk_pixbuf_new_from_inline.
+
 Wed Oct 10 21:13:46 2001  Kristian Rietveld  <kristian@planet.nl>
 
        * gtk/gtktreemodel.[ch]: added gtk_tree_model_get_iter_from_string().
index 7a865042867d5078bc02ef5999bea47ffc190374..ac9a9e96d691bc92c74dd71b5d01ef948ba6fc44 100644 (file)
@@ -1,3 +1,30 @@
+Wed Oct 10 12:48:38 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check): Call setlocale (LC_ALL, "").
+       (#60606)
+
+       * gtk/gtkmain.c (gtk_disable_setlocale): Add function
+       to disable calling setlocale (LC_ALL, "").
+
+       * gtk/gtkmain.c (gtk_set_locale): Indicate in the 
+       docs that this function is not typically useful.
+
+       * gdk/x11/{gdkim-x11.c,gdkmain-x11.c,gdkprivate-x11.h}: 
+       Automatically initialize GDK for the current locale
+       on gdk_init(). Don't reset locale to C when
+       XSupportsLocale() fails.
+
+       * gdk/linux-fb/gdkim-fb.c (gdk_set_locale): Remove
+       useless checks for UTF-8 locale breakage that mattered
+       only for X.
+
+       * examples/calendar/calendar.c
+       tests/{testgtk.c,testtext.c,testcalendar.c}: Remove calls to 
+       gtk_set_locale().
+
+       * gtk/gtkiconfactory.c gtk/gtkitemfactory.c:
+       gdk_pixbuf_new_from_stream => gdk_pixbuf_new_from_inline.
+
 Wed Oct 10 21:13:46 2001  Kristian Rietveld  <kristian@planet.nl>
 
        * gtk/gtktreemodel.[ch]: added gtk_tree_model_get_iter_from_string().
index 7330f40d64987061399ac64b9ef6c8498c85381c..d6e65373bd462fea4aa15a376275424e50223400 100644 (file)
 
 #include <locale.h>
 
-/* If this variable is FALSE, it indicates that we should
- * avoid trying to use multibyte conversion functions and
- * assume everything is 1-byte per character
- */
-static gboolean gdk_use_mb;
-
 /*
  *--------------------------------------------------------------
  * gdk_set_locale
@@ -59,42 +53,10 @@ static gboolean gdk_use_mb;
 gchar*
 gdk_set_locale (void)
 {
-  wchar_t result;
-  gchar *current_locale;
-
-  gdk_use_mb = FALSE;
-
   if (!setlocale (LC_ALL,""))
     g_warning ("locale not supported by C library");
   
-  current_locale = setlocale (LC_ALL, NULL);
-
-  if ((strcmp (current_locale, "C")) && (strcmp (current_locale, "POSIX")))
-    {
-      gdk_use_mb = TRUE;
-
-#ifndef X_LOCALE
-      /* Detect GNU libc, where mb == UTF8. Not useful unless it's
-       * really a UTF8 locale. The below still probably will
-       * screw up on Greek, Cyrillic, etc, encoded as UTF8.
-       */
-      
-      if ((MB_CUR_MAX == 2) &&
-         (mbstowcs (&result, "\xdd\xa5", 1) > 0) &&
-         result == 0x765)
-       {
-         if ((strlen (current_locale) < 4) ||
-             g_strcasecmp (current_locale + strlen(current_locale) - 4, "utf8"))
-           gdk_use_mb = FALSE;
-       }
-#endif /* X_LOCALE */
-    }
-
-  GDK_NOTE (MISC,
-           g_message ("%s multi-byte string functions.", 
-                      gdk_use_mb ? "Using" : "Not using"));
-  
-  return current_locale;
+  return setlocale (LC_ALL, NULL);
 }
 
 /*
index 05fe0764c48a725d6048eb9b2b01bf3faad483b3..bd118b0aa0f7c0c4840e82235f9f41e23fb0a96d 100644 (file)
  */
 static gboolean gdk_use_mb;
 
-/*
- *--------------------------------------------------------------
- * gdk_set_locale
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-gchar*
-gdk_set_locale (void)
+void
+_gdk_x11_initialize_locale (void)
 {
   wchar_t result;
   gchar *current_locale;
+  static char *last_locale = NULL;
 
   gdk_use_mb = FALSE;
 
-  if (!setlocale (LC_ALL,""))
-    g_warning ("locale not supported by C library");
-  
+  current_locale = setlocale (LC_ALL, NULL);
+
+  if (last_locale && strcmp (last_locale, current_locale) == 0)
+    return;
+
+  g_free (last_locale);
+  last_locale = g_strdup (current_locale);
+
   if (!XSupportsLocale ())
-    {
-      g_warning ("locale not supported by Xlib, locale set to C");
-      setlocale (LC_ALL, "C");
-    }
+    g_warning ("locale not supported by Xlib");
   
   if (!XSetLocaleModifiers (""))
     g_warning ("can not set locale modifiers");
 
-  current_locale = setlocale (LC_ALL, NULL);
-
   if ((strcmp (current_locale, "C")) && (strcmp (current_locale, "POSIX")))
     {
       gdk_use_mb = TRUE;
 
 #ifndef X_LOCALE
-      /* Detect GNU libc, where mb == UTF8. Not useful unless it's
+      /* Detect ancient GNU libc, where mb == UTF8. Not useful unless it's
        * really a UTF8 locale. The below still probably will
        * screw up on Greek, Cyrillic, etc, encoded as UTF8.
        */
@@ -109,6 +97,17 @@ gdk_set_locale (void)
   return current_locale;
 }
 
+gchar*
+gdk_set_locale (void)
+{
+  if (!setlocale (LC_ALL,""))
+    g_warning ("locale not supported by C library");
+
+  _gdk_x11_initialize_locale ();
+  
+  return setlocale (LC_ALL, NULL);
+}
+
 /*
  * gdk_wcstombs 
  *
index cf2b41ffeeba82d02e397951fbbf2561c46a5543..e0c2ed61bf5f00127d02bb666139b7783ab66e30 100644 (file)
@@ -116,6 +116,8 @@ _gdk_windowing_init_check (int argc, char **argv)
   XKeyboardState keyboard_state;
   XClassHint *class_hint;
   guint pid;
+
+  _gdk_x11_initialize_locale ();
   
   XSetErrorHandler (gdk_x_error);
   XSetIOErrorHandler (gdk_x_io_error);
index bc8564825ce0282f838ce7b9c084fa362b4b6831..b22b0a3fdd1f777263975d958c4d6fbc31307b47 100644 (file)
@@ -150,6 +150,8 @@ void     _gdk_keymap_state_changed         (void);
 
 GC _gdk_x11_gc_flush (GdkGC *gc);
 
+void _gdk_x11_initialize_locale (void);
+
 extern GdkDrawableClass  _gdk_x11_drawable_class;
 extern Window           _gdk_root_window;
 extern gboolean                 _gdk_use_xshm;